layui.define(["jquery", "qs", "conf", "dayjs", "store", "element", "EventEmitter", "webSocket"], function (exports) {
	var $ = layui.$,
		qs = layui.qs,
		conf = layui.conf,
		pagination = conf.pagination,
		dayjs = layui.dayjs,
		store = layui.store,
		element = layui.element,
		EventEmitter = layui.EventEmitter,
		webSocket = layui.webSocket;

	/**
	 * @author: ares
	 * @date: 2021/3/23 14:08
	 * @description: 是否纯对象  { }|new Object()|Object.create(null)
	 * @param {*}obj
	 * @returns {boolean}
	 */
	function isPlainObject(obj) {
		var proto,
			Ctor,
			class2type = {},
			toString = class2type.toString;

		if (!obj || toString.call(obj) !== "[object Object]") return false;
		var hasOwn = class2type.hasOwnProperty,
			fnToString = hasOwn.toString,
			ObjectFunctionString = fnToString.call(Object),
			getProto = Object.getPrototypeOf;

		proto = getProto(obj);

		// Objects with no prototype (e.g., `Object.create( null )`) are plain
		if (!proto) return true;

		// Objects with prototype are plain iff they were constructed by a global Object function
		Ctor = hasOwn.call(proto, "constructor") && proto.constructor;
		return typeof Ctor === "function" && fnToString.call(Ctor) === ObjectFunctionString;
	}

	/**
	 * @author: ares
	 * @date: 2021/3/23 13:24
	 * @description: 类型判断
	 * @param {*}obj
	 * @returns {*}
	 */
	function toType(obj) {
		if (obj == null) return obj + "";
		var class2type = {},
			types = ['Boolean', 'Number', 'String', 'Function', 'Array', 'Date', 'RegExp', 'Object', 'Error', 'Symbol', 'WebSocket'];
		for (var i = 0; i < types.length; i++) {
			class2type["[object " + types[i] + "]"] = types[i].toLowerCase();
		}
		return typeof obj === "object" || typeof obj === "function" ?
			class2type[toString.call(obj)] || "object" :
			typeof obj;
	}

	function Utils() {
	}

	Utils.prototype = {
		constructor: Utils,
		/**
		 * @author: ares
		 * @date: 2021/3/23 9:08
		 * @description: 全局对象
		 */
		ARES: (function () {
			var websocketPath = location.hostname + ':' + location.port + '/websocket',
				websocketParams = {account: store.get('mobile')},
				topAres = top.ARES;

			if (isPlainObject(topAres)) {
				if (!isPlainObject(topAres.cache)) {
					topAres.cache = {};
				}
				if (toType(topAres.event) != 'object' || topAres.event.constructor.name != 'EventEmitter') {
					console.log('event not define', topAres)
					topAres.event = new EventEmitter();
				}
				if (toType(topAres.webSocket) != 'websocket') {
					// topAres.webSocket = webSocket.init(websocketPath, websocketParams);
				}
				return topAres;
			} else {
				top.ARES = {
					cache: {},
					event: new EventEmitter(),
					// webSocket: webSocket.init(websocketPath, websocketParams),
				};
				return top.ARES;
			}
		})(),
		isPlainObject: isPlainObject,
		type: toType,
		/**
		 * @author:ares
		 * @datetime:2018/1/19 14:12
		 * @description: 给指定dom加载新的页面,默认dom为main
		 * @param      {string}    url
		 * @param      {object}  target   指定的 jQuery dom
		 * @param      {string | boolean}  cache是否缓存
		 * @param      {function}  callback
		 */
		loadView: function (url, target, cache, callback) {
			if (typeof target === 'function') {
				callback = target;
				target = false;
			}
			if (typeof cache === 'function') {
				callback = cache;
				cache = false;
			}
			var tar = target ? target : $("#sys-main-content-wrap");
			tar.empty();
			$.ajaxSetup({cache: !!cache});
			tar.load(url, callback);
		},
		/**
		 * @author:ares
		 * @datetime:2018/1/19 14:12
		 * @description: 给指定dom加载新的iframe页面,默认dom为main
		 * @param      {string}    url
		 * @param      {object}  target   指定的 jQuery dom
		 * @param      {function}  callback
		 */
		loadIframeView: function (url, target, callback) {
			if (typeof target === 'function') {
				callback = target;
				target = false;
			}
			var self = this,
				tar = target ? target : $("#main-view"),
				iframe = document.createElement('iframe');
			iframe.setAttribute('frameborder', 0);
			iframe.src = url;
			iframe.scrolling = 'no';
			iframe.height = '100%';
			iframe.width = '100%';
			iframe.onload = function (event) {
				console.log('iframe--' + url + '加载成功')
				$(iframe.contentDocument).on('click', 'a[href]', function (event) {
					console.log($(this).attr('href'))
					event.preventDefault();
					self.pushTopRoute($(this).attr('href').split('#')[1]);
				})
			}
			tar.empty().append(iframe);
			if (typeof callback == 'function') callback(event);
		},
		/**
		 * @author: ares
		 * @date: 2021/3/23 10:01
		 * @description: iframe页面的a标签触发顶层路由跳转
		 */
		iframeBindSkipTopLinkEvent: function () {
			var self = this;
			$(document).on('click', 'a[href]', function (event) {
				console.log($(this).attr('href'))
				event.preventDefault();
				self.pushTopRoute($(this).attr('href').split('#')[1]);
			})
		},
		/**
		 * @author: ares
		 * @date: 2021/2/22 10:16
		 * @description: 关闭当前系统tab
		 */
		closeCurrentSysTab: function () {
			var tabCloseBtn = top.document.querySelector('#sys-tabs>.layui-this>.layui-tab-close');
			tabCloseBtn && tabCloseBtn.click();
		},
		/**
		 * @author: ares
		 * @date: 2021/2/22 10:16
		 * @description: 移除当前系统tab对应iframe中的print iframe
		 */
		removeCurrentSysPrintIframe: function () {
			var iframe = top.document.querySelector('#sys-tabs-content>.layui-show>iframe'),
				doc = iframe && iframe.contentDocument,
				printAreaIframe = doc && doc.querySelector('.print-area-iframe');
			printAreaIframe && (printAreaIframe.src = '');
		},
		/**
		 * @author: ares
		 * @date: 2021/1/28 10:08
		 * @description: 查询字符串格式化
		 * @param {string|object}query
		 */
		queryFormat: function (query) {
			if (typeof query == 'string') {
				return '?' + query;
			} else if (Object.prototype.toString.call(query) === "[object Object]") {
				return '?' + qs.stringify(query)
			} else {
				return '';
			}
		},
		/**
		 * @author: ares
		 * @date: 2018/12/14 16:05
		 * @description: 切换URL hash
		 * @param {string}hash
		 * @param {string|object}query
		 */
		pushRoute: function (hash, query) {
			window.location = "#" + hash + this.queryFormat(query);
		},
		/**
		 * @author: ares
		 * @date: 2018/12/14 16:05
		 * @description: 切换URL hash
		 * @param {string}hash
		 * @param {string|object}query
		 */
		pushTopRoute: function (hash, query) {
			var topLocation = top.location;
			top.location = topLocation.origin + topLocation.pathname + "#" + hash + this.queryFormat(query);
		},
		/**
		 * @author: ares
		 * @date: 2019/9/3 14:42
		 * @description: 替换 URL hash
		 * @param {string}hash
		 * @param {string|object}query
		 */
		replaceRoute: function (hash, query) {
			window.location.replace("#" + hash + this.queryFormat(query));
		},
		/**
		 * @author: ares
		 * @date: 2019/9/3 14:42
		 * @description: 替换 URL hash
		 * @param {string}hash
		 * @param {string|object}query
		 */
		replaceTopRoute: function (hash, query) {
			var topLocation = top.location;
			top.location.replace(topLocation.origin + topLocation.pathname + "#" + hash + this.queryFormat(query));
		},
		/**
		 * @author: ares
		 * @date: 2021/3/22 9:53
		 * @description: 历史回退
		 */
		historyBack: function () {
			top.history.back();
		},
		/**
		 * @author: ares
		 * @date: 2019/8/20 10:31
		 * @description: 渲染分页器
		 * @param {object} laypage   分页器
		 * @param {object} config    分页器配置
		 * @param {function} callback
		 */
		laypageRender: function (laypage, config, callback) {
			if (typeof config == "function") {
				var temp = config;
				callback = temp;
				config = {};
			}
			config =
				Object.prototype.toString.call(config) === "[object Object]"
					? config
					: {};
			var _config = pagination;
			_config.jump = function (obj, first) {
				if (!first && typeof callback == "function") callback(obj);
			};
			$.extend(_config, config);
			laypage.render(_config);
		},
		/**
		 * @author: ares
		 * @date: 2020/2/16 22:27
		 * @description: 获取分页默认配置
		 */
		getPagerConfig: function () {
			return pagination;
		},
		/**
		 * @author: ares
		 * @date: 2020/12/1 13:55
		 * @description: 清空toast2插件的消息队列
		 * @param {string}containerId
		 */
		clearToast2Message: function (containerId) {
			containerId = containerId || "global-message-stack-container"
			let container = document.getElementById(containerId);
			if (container) container.innerHTML = "";
		},
		/**
		 * @author: ares
		 * @date: 计算入院天数,判断是否是新入院患者
		 * @param hospitalized_timestamp 入院时间戳
		 * @returns {number}入院天数(含当天)
		 */
		newHospitalized: function (hospitalized_timestamp) {
			if (!hospitalized_timestamp) return 0;
			var now_time = dayjs().valueOf();
			var base_time_stamp = dayjs(hospitalized_timestamp).add(1, "day").valueOf();
			var difference_time = now_time - base_time_stamp;

			return Math.ceil(difference_time / 1000 / 60 / 60 / 24) + 1;
		},
		/**
		 * @author: ares
		 * @date: 2021/1/25 10:15
		 * @description: layui单选必选验证
		 */
		requiredRaido: function (value, item) {
			var form = $(item).closest('form'),
				domName = item.getAttribute('name'),
				validValue = form.find('[name="' + domName + '"]:checked').val(),
				label = item.getAttribute('lay-verify-label');
			if (!validValue) {
				utils.msgError(label ? label + '为必选项' : '有单选选项没有选中');
				return true;
			}
		},
		/**
		 * @author: ares
		 * @date: 2021/1/25 10:19
		 * @description: 复选必选按钮
		 */
		requiredCheckBox: function (value, item) {
			var form = $(item).closest('form'),
				label = item.getAttribute('lay-verify-label'),
				validItemNum = form.find('[lay-verify-label="' + label + '"]:checked').length;
			if (!label) return;
			if (validItemNum == 0) {
				utils.msgError(label + '为必选项');
				return true;
			}
		},
		/**
		 * @author: ares
		 * @date: 2021/3/11 9:53
		 * @description: 复选框最少选几个
		 */
		minCheckBox: function (value, item) {
			var form = $(item).closest('form'),
				min = 1 * item.getAttribute('min'),
				label = item.getAttribute('lay-verify-label'),
				validItemNum = form.find('[lay-verify-label="' + label + '"]:checked').length;
			if (!label) return;
			if (validItemNum < min) {
				utils.msgError(label + '数量不能小于' + min);
				return true;
			}
		},
		/**
		 * @author: ares
		 * @date: 2021/3/11 9:53
		 * @description: 复选框最多选几个
		 */
		maxCheckBox: function (value, item) {
			var form = $(item).closest('form'),
				max = 1 * item.getAttribute('max'),
				label = item.getAttribute('lay-verify-label'),
				validItemNum = form.find('[lay-verify-label="' + label + '"]:checked').length;
			if (!label) return;
			if (validItemNum > max) {
				utils.msgError(label + '数量不能大于' + max);
				return true;
			}
		},
		/**
		 * @author: ares
		 * @date: 2021/1/25 10:19
		 * @description: 最小验证
		 */
		minVerify: function (value, item) {
			var min = 1 * item.getAttribute('min'),
				label = item.getAttribute('lay-verify-label');
			if (value && value < min) return label ? label + '最小值不能小于' + min : '最小值不能小于' + min;
		},
		/**
		 * @author: ares
		 * @date: 2021/1/25 10:19
		 * @description: 最大验证
		 */
		maxVerify: function (value, item) {
			var max = 1 * item.getAttribute('max'),
				label = item.getAttribute('lay-verify-label');
			if (value && value > max) return label ? label + '最大值不能大于' + max : '最大值不能大于' + max;
		},
		/**
		 * @author: ares
		 * @date: 2021/1/25 10:19
		 * @description: 最小最大范围验证
		 */
		rangeVerify: function (value, item) {
			var min = 1 * item.getAttribute('min'),
				max = 1 * item.getAttribute('max'),
				label = item.getAttribute('lay-verify-label');
			if (value && (value < min || value > max)) return label ? label + '范围' + min + '~' + max : '范围' + min + '~' + max;
		},
		/**
		 * @author: ares
		 * @date: 2021/1/25 10:19
		 * @description: 最小长度验证
		 */
		minLengthVerify: function (value, item) {
			var minLength = 1 * item.getAttribute('minLength'),
				label = item.getAttribute('lay-verify-label');
			if (value && value.length < minLength) return label ? label + '长度不能小于' + minLength : '长度不能小于' + minLength;
		},
		/**
		 * @author: ares
		 * @date: 2021/1/25 10:19
		 * @description: 最大长度验证
		 */
		maxLengthVerify: function (value, item) {
			var maxLength = 1 * item.getAttribute('maxLength'),
				label = item.getAttribute('lay-verify-label');
			if (value && value.length > maxLength) return label ? label + '长度不能大于' + maxLength : '长度不能大于' + maxLength;
		},
		/**
		 * @author: ares
		 * @date: 2021/1/25 10:19
		 * @description: 最小长度最大长度范围验证
		 */
		rangeLengthVerify: function (value, item) {
			var minLength = 1 * item.getAttribute('minLength'),
				maxLength = 1 * item.getAttribute('maxLength'),
				label = item.getAttribute('lay-verify-label');
			if (value && (value.length < minLength || value.length > maxLength)) return label ? label + '长度范围' + minLength + '~' + maxLength : '长度范围' + minLength + '~' + maxLength;
		},
		/**
		 * @author: ares
		 * @date: 2021/2/1 16:19
		 * @description: 页面事件监听初始化
		 * @param{string} eventType   事件类型
		 * @param{string} cacheType   缓存数据名称
		 * @param{function} callback
		 */
		aresPageEventInit: function (eventType, cacheType, callback) {
			if (typeof cacheType == 'function') {
				callback = cacheType;
				cacheType = 'cache';
			}
			cacheType = cacheType || 'cache';
			if (!utils.ARES.event) return;
			utils.ARES.event.removeEvent(eventType);
			utils.ARES.event.on(eventType, function (data) {
				utils.ARES.cache[cacheType] = null;
				if (typeof callback == 'function') callback(data);
			})
		},
		/**
		 * @author: ares
		 * @date: 2020/6/3 16:27
		 * @description: 启用禁用
		 * @param {number}status  0|1
		 * @param {string}text    类似启用禁用的状态  如'上架|下架'
		 * @param {boolean}revers    反转启用/禁用
		 * @returns {string}
		 */
		setEnableOrDisable: function (status, text, revers) {
			var trueTxt = typeof text === 'string' ? text.split('|')[0] : '启用';
			var falseTxt = typeof text === 'string' ? text.split('|')[1] : '禁用';
			return revers ? '<b class="' + (status ? "ares-text-red" : "ares-text-green") + '">' + (status ? falseTxt : trueTxt) + '</b>'
				: '<b class="' + (status ? "ares-text-green" : "ares-text-red") + '">' + (status ? trueTxt : falseTxt) + '</b>';
		},
		/**
		 * @author: ares
		 * @date: 2020/12/16 21:58
		 * @description: 更新面包屑导航
		 * @param{object} router
		 */
		updateBreadcrumb: function (router) {
			if (!router || !router.meta) return;
			var breadcrumbData = router.meta.breadcrumb || [],
				$breadcrumb = $('#sys-breadcrumb'),
				$fragment = $(document.createDocumentFragment()),
				isHome = breadcrumbData.length == 1 && breadcrumbData[0].path == conf.homePagePath;
			//面包屑首项是首页
			$fragment.append('<a href="#' + conf.homePagePath + '">' + conf.homePageTitle + '</a>');
			if (!isHome) {
				$.each(breadcrumbData, function (index, item) {
					//更新面包屑导航
					if (index == breadcrumbData.length - 1) {
						$fragment.append('<a>' + item.title + '</a>');
					} else {
						if (item.path) {
							$fragment.append('<a href="#' + item.path + '">' + item.title + '</a>');
						} else {
							$fragment.append('<a>' + item.title + '</a>');
						}
					}
				})
			}
			$breadcrumb.empty().append($fragment);
			element.render('breadcrumb');
		},
		/**
		 * @author: ares
		 * @date: 2020/12/26 21:37
		 * @description: 高亮显示侧边菜单
		 */
		highLightAside: function () {
			var $asideMenus = sideMainItem = $("#side-tree-menu>.layui-nav-item,#side-tree-menu .layui-nav-child>dd");
			$fragment = $(document.createDocumentFragment());
			$asideMenus.removeClass('layui-this');
			$asideMenus.each(function (i, menu) {
				var href = $(this).children('a').attr('href').substr(1);
				if (href == location.hash.slice(1).split('?')[0]) {
					$(this).addClass('layui-this');
				}
			})
		},
		/**
		 * @author: ares
		 * @date: 2021/3/8 12:53
		 * @description: 重写layui固定块
		 * @param options
		 */
		fixbar: function (options) {
			var ELEM = 'layui-fixbar', TOP_BAR = 'layui-fixbar-top'
				, dom = $(document), body = $('body')
				, is, timer,
				scrollDom = options.scrollDom ? $(options.scrollDom) : dom;

			options = $.extend({
				showHeight: 200 //出现TOP的滚动条高度临界值,
			}, options);

			options.bar1 = options.bar1 === true ? '&#xe606;' : options.bar1;
			options.bar2 = options.bar2 === true ? '&#xe607;' : options.bar2;
			options.bgcolor = options.bgcolor ? ('background-color:' + options.bgcolor) : '';

			var icon = [options.bar1, options.bar2, '&#xe604;'] //图标：信息、问号、TOP
				, elem = $(['<ul class="' + ELEM + '">'
				, options.bar1 ? '<li class="layui-icon" lay-type="bar1" style="' + options.bgcolor + '">' + icon[0] + '</li>' : ''
				, options.bar2 ? '<li class="layui-icon" lay-type="bar2" style="' + options.bgcolor + '">' + icon[1] + '</li>' : ''
				, '<li class="layui-icon ' + TOP_BAR + '" lay-type="top" style="' + options.bgcolor + '">' + icon[2] + '</li>'
				, '</ul>'].join(''))
				, topBar = elem.find('.' + TOP_BAR)
				, scroll = function () {
				var stop = scrollDom.scrollTop();
				if (stop >= (options.showHeight)) {
					is || (topBar.show(), is = 1);
				} else {
					is && (topBar.hide(), is = 0);
				}
			};
			if ($('.' + ELEM)[0]) return;

			typeof options.css === 'object' && elem.css(options.css);
			body.append(elem), scroll();

			//bar点击事件
			elem.find('li').on('click', function () {
				var othis = $(this), type = othis.attr('lay-type');
				if (type === 'top') {
					$('html,body,.layui-body').animate({
						scrollTop: 0
					}, 200);
				}
				options.click && options.click.call(this, type);
			});

			//Top显示控制
			scrollDom.on('scroll', function (e) {
				clearTimeout(timer);
				timer = setTimeout(function () {
					scroll();
				}, 100);
			});
		},
		/**
		 * @author: ares
		 * @date: 2021/3/10 10:57
		 * @description: 加密患者名字
		 */
		getPrivatePatientName: function (name) {
			if (!name) return '';
			return name.substring(0, 1) + "**";
		},
		/**
		 * @author: ares
		 * @date: 2021/3/19 11:50
		 * @description: top layer
		 */
		layer: (function () {
			return top.layer;
		})(),
		/**
		 * @author: ares
		 * @date: 2021/3/19 11:50
		 * @description: top layer close
		 */
		layerClose: function (index) {
			return top.layer.close(index);
		},
		/**
		 * @author: ares
		 * @date: 2021/3/19 11:50
		 * @description: top layer closeAll
		 */
		layerCloseAll: function (type) {
			return top.layer.closeAll(type);
		},
		/**
		 * @author: ares
		 * @date: 2021/3/19 11:50
		 * @description: top layer open
		 */
		layerOpen: function () {
			return top.layer.open.apply(top, arguments);
		},
		/**
		 * @author: ares
		 * @date: 2021/3/19 11:50
		 * @description: top layer tips
		 */
		layerTips: function () {
			return top.layer.tips.apply(top, arguments);
		},
		/**
		 * @author: ares
		 * @date: 2021/3/19 11:50
		 * @description: top layer load
		 * @param{string} msg  文案
		 * @param{object} msg  配置
		 */
		layerLoading: function (icon, config) {
			if (toType(icon) == 'object') {
				config = icon;
				icon = 3;
			}
			icon = toType(icon) == 'number' ? icon : 3;
			var _conf = {time: false};
			$.extend(_conf, config)
			return top.layer.load(icon || 3, _conf);
		},
		/**
		 * @author: ares
		 * @date: 2021/3/19 11:50
		 * @description: top layer msg
		 * @param{string} msg  文案
		 * @param{object} msg  配置
		 */
		layerLoadingMsg: function (msg, config) {
			var _conf = {icon: 16, time: false, shade: 0.8};
			$.extend(_conf, config)
			return top.layer.msg(msg, _conf);
		},
		/**
		 * @author: ares
		 * @date: 2021/3/19 8:54
		 * @description: 消息提示
		 */
		message: function () {
			top.layer.msg.apply(top, arguments)
		},
		/**
		 * @author: ares
		 * @date: 2021/3/19 8:52
		 * @description: 成功提示
		 * @param {string}msg  消息
		 */
		msgSuccess: function (msg) {
			top.layer.msg(msg, {icon: 1});
		},
		/**
		 * @author: ares
		 * @date: 2021/3/19 8:55
		 * @description: 错误提示
		 * @param {string}msg  消息
		 */
		msgError: function (msg) {
			top.layer.msg(msg, {icon: 2});
		},
		/**
		 * @author: ares
		 * @date: 2021/3/19 8:58
		 * @description: 疑问提示
		 * @param {string}msg   消息
		 */
		msgAsk: function (msg) {
			top.layer.msg(msg, {icon: 3});
		},
		/**
		 * @author: ares
		 * @date: 2021/3/19 8:59
		 * @description: 锁定提示
		 * @param {string}msg   消息
		 */
		msgLock: function (msg) {
			top.layer.msg(msg, {icon: 4});
		},
		/**
		 * @author: ares
		 * @date: 2021/3/19 9:00
		 * @description: 难过提示
		 * @param {string}msg   消息
		 */
		msgSad: function (msg) {
			top.layer.msg(msg, {icon: 5});
		},
		/**
		 * @author: ares
		 * @date: 2021/3/19 9:01
		 * @description: 开心提示
		 * @param {string}msg   消息
		 */
		msgHappy: function (msg) {
			top.layer.msg(msg, {icon: 6});
		},
		/**
		 * @author: ares
		 * @date: 2021/3/19 9:01
		 * @description: 警告提示
		 * @param {string}msg   消息
		 */
		msgWarning: function (msg) {
			top.layer.msg(msg, {icon: 7});
		},
		/**
		 * @author: ares
		 * @date: 2021/3/19 9:05
		 * @description: alert
		 */
		alert: function () {
			return top.layer.alert.apply(top, arguments);
		},
		/**
		 * @author: ares
		 * @date: 2021/3/19 11:20
		 * @description: confirm
		 */
		confirm: function () {
			return top.layer.confirm.apply(top, arguments);
		},
		/**
		 * @author: ares
		 * @date: 2021/3/25 12:03
		 * @description: 登录用户是否是治疗师
		 */
		isTherapist: function () {
			var currentUserInfo = store.get('currentUserInfo');
			return currentUserInfo && currentUserInfo.job == 'therapist' ? true : false;
		},
		/**
		 * @author: ares
		 * @date: 2021/3/25 16:53
		 * @description: 生成单选组
		 * @param {string}name  radio的name属性值
		 * @param {array}list   数据
		 * @param {string}checked 选中项
		 * @param {object}config  配置
		 * @returns {HTMLElement}
		 */
		createRadio: function (name, list, checked, config) {
			if (!Array.isArray(list)) return;
			if ($.isPlainObject(checked)) {
				config = checked;
				checked = null;
			}
			var _config = {
				name: 'v',
				value: 'k'
			};
			$.extend(_config, config)
			var $fragment = $(document.createDocumentFragment());
			$.each(list, function (index, item) {
				var $radio = $('<input type="radio" name="' + name + '" value="' + item[_config.value] + '" title="' + item[_config.name] + '">');
				if (item[_config.value] == checked) $radio.prop('checked', true);
				if ($.isPlainObject(_config.verify)) {
					for (key in _config.verify) {
						$radio.attr(key, _config.verify[key])
					}
				}
				$fragment.append($radio);
			});
			return $fragment;
		},
		/**
		 * @author: ares
		 * @date: 2021/3/25 20:25
		 * @description: 生成复选组
		 * @param {string}name  radio的name属性值
		 * @param {array}list   数据
		 * @param {array}checked 选中项
		 * @param {object}config  配置
		 * @returns {HTMLElement}
		 */
		createCheckbox: function (name, list, checked, config) {
			if (!Array.isArray(list)) return;
			if ($.isPlainObject(checked)) {
				config = checked;
				checked = [];
			}
			if (!Array.isArray(checked)) checked = [];
			var _config = {
				name: 'v',
				value: 'k'
			};
			$.extend(_config, config)
			var $fragment = $(document.createDocumentFragment());
			$.each(list, function (index, item) {
				var $checkbox = $('<input type="checkbox" name="' + name + '_' + item[_config.value] + '" value="' + item[_config.value] + '" title="' + item[_config.name] + '" lay-skin="primary">');
				if ($.inArray(item[_config.value], checked) >= 0) $checkbox.prop('checked', true);
				if ($.isPlainObject(_config.verify)) {
					for (key in _config.verify) {
						$checkbox.attr(key, _config.verify[key])
					}
				}
				$fragment.append($checkbox);
			});
			return $fragment;
		},
		/**
		 * @author: ares
		 * @date: 2021/3/25 16:56
		 * @description: 生成下拉选项
		 * @param {string}name  select的name和id属性值
		 * @param {array}list   数据
		 * @param {string}selected  选中项
		 * @param {object}config    配置
		 * @returns {HTMLElement}
		 */
		createSelect: function (name, list, selected, config) {
			if (!Array.isArray(list)) return;
			if ($.isPlainObject(selected)) {
				config = selected;
				selected = null;
			}
			var _config = {
				name: 'v',
				value: 'k'
			};
			$.extend(_config, config)
			var $fragment = $(document.createDocumentFragment()),
				$select = $('<select id="' + name + '" name="' + name + '"></select>');
			if ($.isPlainObject(_config.verify)) {
				for (key in _config.verify) {
					$select.attr(key, _config.verify[key])
				}
			}
			$select.append('<option value="">请选择</option>');
			$.each(list, function (index, item) {
				var $option = $('<option value="' + item[_config.value] + '">' + item[_config.name] + '</option>');
				if (item[_config.value] == selected) $option.prop('selected', true);
				$select.append($option);
			});
			$fragment.append($select);
			return $fragment;
		},
		/**
		 * @author: ares
		 * @date: 2021/4/28 10:34
		 * @description: 构造函数原型继承
		 * @param {function}Sub   子类
		 * @param {function}Super  父类
		 */
		inheritPrototype: function (Sub, Super) {
			var prototype = Object.create(Super.prototype);
			prototype.constructor = Sub;
			Sub.prototype = prototype;
		}
	};

	var utils = new Utils();

	exports("utils", utils);
});
